//
//  GameOverScene.cpp
//  XTest
//
//  Created by 100TV protocal on 12-11-13.
//
//

#include "GameOverScene.h"
#include "HelloWorldScene.h"

using namespace cocos2d;

CCScene* GameOverScene::scene()
{
    CCScene *scene = CCScene::create();
    
    // 'layer' is an autorelease object
    GameOverScene * layer = GameOverScene::create();
    
    // add layer as a child to scene
    scene->addChild(layer);
    
    // return the scene
    return scene;
}


bool GameOverScene::init()
{
    if(!CCScene::init())
    {
        return false;
    }
    // do something
    this->_layer = (GameOverLayer *)GameOverLayer::create();
    this->addChild(_layer);
    
    return true;
}

void GameOverScene::onExit()
{
    // do something
//    _layer->release();
//    _layer = NULL;
//    CCLayerColor::onExit();
}

////////////////////////////////////////////////////////////

bool GameOverLayer::init()
{
    if (!CCLayerColor::initWithColor(ccc4(255,0,255,255))) {
        return false;
    }
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    this->_label = CCLabelTTF::create("the string", "Marker Felt", 21);
    this->_label->setColor(ccc3(0, 0, 0));
    this->_label->setPosition(ccp(winSize.width/2, winSize.height/2));
    this->addChild(this->_label);
    
    CCAction * actionMoveDone = CCSequence::create(CCDelayTime::create(3.0),
                                                   CCCallFuncND::create(this,
                                                                        callfuncND_selector(GameOverLayer::gameOverDone),
                                                                        NULL),
                                                   NULL);
    
    this->runAction(actionMoveDone);
    
    return true;
}

void GameOverLayer::gameOverDone()
{
    CCDirector::sharedDirector()->replaceScene(HelloWorld::scene());
}

void GameOverLayer::onExit()
{
//    _label->release();
//    _label=NULL;
//    CCLayerColor::onExit();
}


















